using System;
using Csla;

namespace ENT.GP.Core.Tareas
{
    [Serializable]
    public class TareaCriterio : BusinessBase<TareaCriterio>
    {
        #region Business Methods

        private static PropertyInfo<int> IdUsuarioProperty = RegisterProperty<int>(o => o.IdUsuario, "Name");
        public int IdUsuario
        {
            get { return GetProperty(IdUsuarioProperty); }
            set { SetProperty(IdUsuarioProperty, value); }
        }

        private static PropertyInfo<int> IdRolProperty = RegisterProperty<int>(o => o.IdRol, "Name");
        public int IdRol
        {
            get { return GetProperty(IdRolProperty); }
            set { SetProperty(IdRolProperty, value); }
        }

        private static PropertyInfo<int> IdProyectoProperty = RegisterProperty<int>(o => o.IdProyecto, "Name");
        public int IdProyecto
        {
            get { return GetProperty(IdProyectoProperty); }
            set { SetProperty(IdProyectoProperty, value); }
        }

        #endregion

        #region Validation Rules

        protected override void AddBusinessRules()
        {
            // TODO: add validation rules
            //ValidationRules.AddRule(RuleMethod, "");
        }

        #endregion

        #region Authorization Rules

        protected override void AddAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowWrite("Name", "Role");
        }

        private static void AddObjectAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowEdit(typeof(TareaCriterio), "Role");
        }

        #endregion

        #region Factory Methods

        public static TareaCriterio NewEditableRoot()
        {
            return DataPortal.Create<TareaCriterio>();
        }

        public static TareaCriterio GetEditableRoot(int id)
        {
            return DataPortal.Fetch<TareaCriterio>(
              new SingleCriteria<TareaCriterio, int>(id));
        }

        public static void DeleteEditableRoot(int id)
        {
            DataPortal.Delete(new SingleCriteria<TareaCriterio, int>(id));
        }

        private TareaCriterio()
        { /* Require use of factory methods */ }

        #endregion

        
    }
}
